<template>
<!--
  有些属性没有提示
-->
  <div >
    <el-table
      border
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址"
        width="180">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间">
      </el-table-column>
    </el-table>

<!--
  分页
  :page-size="5" 每页展示的条数
  :current-page="1" 当前页码
  :total="1000" 总条数

 -->
    <el-pagination
      align="right"
      background
      layout="prev, pager, next"
      :page-size="pageSize"
      :current-page="currentPage"
      :total="totals"
      @current-change="changPage"
    >
    </el-pagination>
  </div>
</template>

<script>

export default {
  name: 'Emp',
  data () {
    return {
      tableData: [],
      pageSize:5, // 每页展示5条
      currentPage:1, // 当前页码
      totals:0 // 总条数
    }
  },

  // 方法
  methods:{
    // 页码触发事件
    changPage(cp) {
      this.currentPage=cp
      this.list()
    },

    //列表首页展示
    list() {
      this.$http.post("/user/list", {"pageSize":this.pageSize, "currentPage":this.currentPage})
      .then(result=>{
        this.tableData=result.data.rows
        this.totals=result.data.totals
      })
      .catch(reason => {
        alert("系统繁忙,请稍后再试!")
      })
    },
  },
  // 钩子函数
  mounted() {
    this.list()
  }


}
</script>

<style>
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>

